package org.wmq.organizationmanagement.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.wmq.organizationmanagement.common.Result;
import org.wmq.organizationmanagement.model.dto.LoginDTO;
import org.wmq.organizationmanagement.model.dto.RegisterDTO;
import org.wmq.organizationmanagement.service.AdminService;
import org.wmq.organizationmanagement.service.LoginService;

@RestController
@RequiredArgsConstructor
@Slf4j
public class LoginController {
    private final LoginService loginService;
    @PostMapping("/login")
    public Result<String> login(@RequestBody LoginDTO loginDTO){
        log.info("用户正在登录，用户名为{},密码为{}",loginDTO.getName(),loginDTO.getPassword());
        return this.loginService.login(loginDTO);
    }

    @PostMapping("register")
    public Result<Void> register(@RequestBody RegisterDTO registerDTO){
        return this.loginService.register(registerDTO);
    }
}
